package com.bzkj.web.controller.basic;

import com.bzkj.basicinfo.domain.basic.BasicStoUnit;
import com.bzkj.basicinfo.service.basic.BasicStoUnitService;
import com.bzkj.common.annotation.LogC;
import com.bzkj.common.core.controller.BaseController;
import com.bzkj.common.core.domain.AjaxResult;
import com.bzkj.common.core.page.TableDataInfo;
import com.bzkj.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author wangzhichao
 * @ClassName BasicStoUnitController
 * @Date 2024/12/13 12:10:17
 * @description 库位信息
 */
@RestController
@RequestMapping("basic/stoUnit")
public class BasicStoUnitController extends BaseController {
    @Autowired
    private BasicStoUnitService basicStoUnitService;

    /**
     * 查询库位信息
     *
     * @Author wangzhichao
     * @Date 2024/12/13 12:16:36
     * @Param entity
     */
    @PreAuthorize("@ss.hasPermi('index:position:query')")
    @GetMapping("findBasicStoUnit")
    public TableDataInfo findBasicStoUnit(BasicStoUnit entity) {
        startPage();
        return getDataTable(basicStoUnitService.findBasicStoUnit(entity));
    }

    /**
     * 批量修改货位状态
     * @Author wangzhichao
     * @Date 2024/12/17 15:25:43
     * @Param list
     * @Param status
     */
    @PreAuthorize("@ss.hasPermi('index:position:stateAllEdit')")
    @PutMapping("updateBasicStoUnitEnableStatusAll")
    @LogC(title = "货位管理", businessType = BusinessType.BATCHUPDATE)
    public AjaxResult updateBasicStoUnitEnableStatusAll(@RequestBody List<Integer> list, @RequestParam String status) {
        return basicStoUnitService.updateBasicStoUnitEnableStatusAll(list, status);
    }

    /**
     * 修改货位状态
     * @Author wangzhichao
     * @Date 2024/12/17 15:28:35
     * @Param status
     * @Param id
     */
    @PreAuthorize("@ss.hasPermi('index:position:stateEdit')")
    @PutMapping("updateBasicStoUnitEnableStatus")
    @LogC(title = "货位管理", businessType = BusinessType.UPDATE, pkFieldNames = "sto_unit_id",
            tableNames = "basic_sto_unit",content = "'货位code：'+#stoUnitCode"
    )
    public AjaxResult updateBasicStoUnitEnableStatus(@RequestParam String enableState, @RequestParam String stoUnitId,@RequestParam String stoUnitCode) {
        return basicStoUnitService.updateBasicStoUnitEnableStatus(enableState,stoUnitId);   // basic_sto_unit
    }
    /**
     * 删除货位
     * @Author swj
     * @Date 2025/05/09
     * @Param stoUnitId 货位id
     */
    @PreAuthorize("@ss.hasPermi('index:position:delete')")
    @DeleteMapping("deleteByStoUnitId")
    @LogC(title = "货位管理", businessType = BusinessType.DELETE,content = "'货位id：'+#stoUnitId")
    public AjaxResult deleteByStoUnitId( @RequestParam String stoUnitId) {
        return basicStoUnitService.deleteByStoUnitId(stoUnitId);// basic_sto_unit
    }
    /**
     * 批量删除货位
     * @Author swj
     * @Date 2025/05/09
     * @Param stoUnitIds 货位id集合
     */
    @PreAuthorize("@ss.hasPermi('index:position:delete')")
    @DeleteMapping("batchDeleteByStoUnitId")
    @LogC(title = "货位管理", businessType = BusinessType.DELETE,content = "'货位id：'+#stoUnitIds")
    public AjaxResult batchDeleteByStoUnitId(@RequestBody List<String> stoUnitIds) {
         return basicStoUnitService.batchDeleteByStoUnitId(stoUnitIds);   // basic_sto_unit
    }

    /**
     * 打印货位信息
     */
    @PreAuthorize("@ss.hasPermi('index:position:print')")
    @PostMapping("printStoUnit")
    @LogC(title = "货位", businessType = BusinessType.PRINT)
    public AjaxResult printStoUnit(@RequestBody List<Integer> stoUnitIds) {
        return basicStoUnitService.printStoUnit(stoUnitIds);
    }

}
